package com.lw.yygh.user.interceptor;

import com.lw.yygh.exception.YyghException;
import com.lw.yygh.result.ResultCodeEnum;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class JwtInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if (!StringUtils.isEmpty( request.getHeader( "token" ) )) {
            return true;
        }
        throw new YyghException( ResultCodeEnum.LOGIN_AUTH );
    }
}
